<?php
/**
 * Created by PhpStorm.
 * User: sosyuki
 * Date: 2018/5/30
 * Time: 14:18
 */

namespace Drupal\distribution\ViewsController;


use Drupal\distribution\ViewsController\handler\field\DistributionApplyFieldEditLink;
use Drupal\distribution\ViewsController\handler\field\DistributionApplyFieldShowStatus;
use Drupal\distribution\ViewsController\handler\filter\DistributionApplyFilterShowStatus;
use EntityDefaultViewsController;

class DistributionApplyViewsController extends EntityDefaultViewsController {

  function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $data[$table]['edit_link'] = [
        'title' => t('申请编辑链接'),
        'help' => t('申请编辑链接.'),
        'field' => [
          'handler' => DistributionApplyFieldEditLink::class,
        ],
      ];
      $data[$table]['show_status'] = [
        'title' => t('申请状态'),
        'help' => t('申请状态.'),
        'real field' => 'status',
        'field' => [
          'handler' => DistributionApplyFieldShowStatus::class,
        ],
        'filter' => [
          'handler' => DistributionApplyFilterShowStatus::class,
        ],
        'sort' => [
          'handler' => 'views_handler_sort',
        ],
      ];
    }
    return $data;
  }


}
